package com.letfox.common.util.http;

/**
 * 错误码
 *
 */
public enum HTTPStatusEnum {
    
    V0000("0000", "请求成功"),
    V0001("V0001", "请求参数触发必填项验证"),
    V0002("V0002", "请求参数类型与实际类型不符"),
    V0003("V0003", "请求参数值长度不正常"),
    V0004("V0004", "服务不可用"),
    V0005("V0005", "验证服务发生异常"),
    V0006("V0006", "服务发生异常");    
    
    

    private String code;
    private String desc;

    private HTTPStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    
    public static HTTPStatusEnum nameOf(String code) {
        for (HTTPStatusEnum st : values()) {
            if (code.matches(st.code)) {
                return st;
            }
        }
        return null;
    }
    
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @Override
    public String toString() {
        return code + desc;
    }
}
